<template>
	<div class="">
		<form class="form-cont">
			<div class="form-title clearFix">
				<p>详细项目</p>
			</div>
			<div class="form-basetop basetop-weui clearFix">
				<x-input title="姓名：" v-model="list.empName"  readonly></x-input>
				<x-input title="部门：" v-model="list.deptName" readonly></x-input>
			</div>

			<div class="form-baseinput">
				<div class="form-group formline form-weui">
					<datetime v-if="!stateX" v-model="dateFirst" title="事发日期：" class="from-contrl"></datetime>
					<x-input v-if="stateX" title="事发日期：" v-model="dateFirst" readonly></x-input>
				</div>
				<div class="form-group formline">
					<label>事发时间：</label>
					<input type="time" name="timeFirst" v-model="timeFirst" required tips="事发时间" placeholder="事发时间" class="form-control">
				</div>
				<!--<div class="form-group formline form-weui">
					<label>事发地点：</label>
					<input type="text" name="incidentSite" required tips="事发地点" class="form-control" v-model="list.incidentSite" placeholder="事发地点(必填)">
				</div>-->

				<group id="safeMeeting">
					<div isrequired="isrequired" class="ipt MeetingStyle weui-new" tips="地点">
						<x-input title="事发地点 : " placeholder="事发地点(必填)"  v-model="list.incidentSite" :show-clear="false"></x-input>
					</div>
				</group>
				<div class="form-group formline form-date">
					<label>事发城市：</label>
					<div class="form-dategroup">
						<div id='province' style="display: inline-block">
							<select id="provinceValue"><option>省份</option></select>
						</div> 
						<div id='city' style="display:inline-block">
							<select id="cityValue"><option>城市</option></select>
						</div> 
					</div>
				</div>


				<div class="form-group form-check-full checkedclass">
					<label>该路段是否做过道路风险评估：</label>
					<div class="checkyw">
						<label>
							<input type="radio" name="dange" v-model="list.isAssess" value="1"> 有
						</label>
						<label>
							<input type="radio" name="dange" v-model="list.isAssess" value="0"> 没有
						</label>
					</div>
				</div>

				<div class="form-group form-check-full inputfull form-sel">
					<selector title="事故类型：" v-model="list.accidentType" :options="carObj.listOne" ></selector>
				</div>



				<div class="form-group form-check-full inputfull form-sel">
					<selector title="事件发生时用车目的：" v-model="list.aimId" :options="carObj.listTwo" ></selector>
				</div>


				
				<div class="form-group form-check-full inputfull form-sel">
					<selector title="当日身体状况：" v-model="list.bodyState" :options="carObj.listThree" ></selector>
				</div>
				<group id="safeMeeting">
					<div isrequired="isrequired" class="ipt MeetingStyle weui-new" tips ="我方车速">
						<x-input title="当时我方车速 : " placeholder="我方车速(必填)"  v-model="list.carSpeed" :show-clear="false"></x-input>
					</div>
				</group>
				<div class="form-group form-check-full inputfull form-sel">
					<selector title="车道信息：" v-model="list.roadwayCount" :options="carObj.listFour" ></selector>
				</div>
				<!-- <div class="form-group form-check-full inputfull">
					<label>道路情况：</label>
					<select class="form-control" v-model="list.roadState">
						<option v-for="sites in roadCondition" v-bind:value="sites.id">
							{{sites.typeName}}
						</option>
					</select>
				</div> -->
				<!-- <div class="form-group form-check-full inputfull">
					<label>车道通行方向：</label>
					<select class="form-control" v-model="list.roadwayAspect">
						<option v-for="site in tafficDirection" v-bind:value="site.id">
							{{site.typeName}}
						</option>
					</select>
				</div> -->
				<div class="form-group form-check-full inputfull">
					<label>当日天气情况：</label>
					<input type="text" name="weatherState" class="form-control" required tips="当日天气情况" id="weather" v-model="weatherText" readonly="" @click="openDiage()" placeholder="当日天气情况(必填)">


					<!-- <select class="form-control" v-model="list.weatherState">
						<option v-for="sites in weather" v-bind:value="sites.id">
							{{sites.typeName}}
						</option>
					</select> -->
				</div>
<!-- 				<div class="form-group form-check-full inputfull">
					<label>我车位置：</label>
					<input type="text" name="carPosition" class="form-control" required tips="我车位置" id="carPosition" v-model="enterTextCar" readonly="" @click="openDiage('carposition')" placeholder="我车位置">
				</div> -->
				<!-- <div class="form-group form-check-full inputfull">
					<label>路面状况：</label>
					<input type="text" name="roadbed" class="form-control" required tips="路面状况" id="roadbed" v-model="roadbedText" readonly="" @click="openDiage('roadbed')" placeholder="路面状况">
				</div> -->
				<!--<div class="form-group form-check-full inputfull">
					<label>车辆预计修理金额：</label>
					<input type="number" name="" class="form-control" required tips="车辆预计修理金额" v-model="list.repairAccount" placeholder="大致金额(必填)">
				</div>-->
				<group id="safeMeeting">
					<div isrequired="isrequired" class="ipt MeetingStyle weui-new add-margin" tips ="车辆预计修理金额">
						<x-input title="车辆预计修理金额 : " placeholder="大致金额(必填)"  v-model="list.repairAccount" :show-clear="false"></x-input>
					</div>
				</group>
				<div class="form-group form-check-full inputfull form-sel">
					<selector title="其他涉及人员：" v-model="list.involvePersonnel" :options="carObj.listFive" ></selector>
				</div>
				<div class="form-group">
					<textarea name="missDescribe" rows="3" class="form-control" placeholder="如有，请提供受伤情况描述" v-model="list.injuredDescribe"></textarea>
				</div>
			</div>

			
			<div class="form-textarea">
				<div class="form-title clearFix">
					<p>事件描述</p>
				</div>
				<div class="form-group">
					<textarea name="missDescribe" rows="3" class="form-control" required tips="事件描述" placeholder="时间、地点、发生了什么事、有何影响(必填)" v-model="list.incidentDescribing"></textarea>
				</div>
	
				<div class="form-title clearFix">
					<p>车辆损伤部位</p>
				</div>
				<div class="form-group">
					<textarea name="missStep" rows="3" class="form-control" required tips="车辆损伤部位" placeholder="车辆损伤部位(必填)" v-model="list.carHarm"></textarea>
				</div>
				<div class="form-title clearFix">
					<p>事故经验分享</p>
				</div>
				<div class="form-group">
					<textarea rows="3" class="form-control" required tips="事故经验分享" placeholder="分享经验或教训(必填)" v-model="list.incidentExperience"></textarea>
				</div>
			</div>

			
			<div class="form-title clearFix">
				<p>是否已报告</p>
			</div>
			<div class="form-group form-check-full clearFix">
				<div class="form-checkmuch clearFix">
					<label v-for="item in report">
						<input type="checkbox" :value="item.id" v-model="isReport" @change="showDecidePicId($event,item)"> {{item.typeName}}
					</label>
				</div>
			</div>
			
			<div class="form-group" v-if="isTrue">
				<div class="form-title clearFix">
					<p>交警事故认定书</p>
				</div>
				<div class="form-group uploadimage" id="uploadDecideimage">
					<ul>
						<li v-for="(img,index) in decideimgs">
							<img :src="img" @click="previewDecideCarImg(img)"/>
							<i class="ion ion-ios-close" v-if="$route.query.state != '01' && $route.query.state != '02'" @click.stop.prevent="delImg('decide',img,index)"></i>
						</li>
						<li>
							<a class="companypic" id="choosedecideImages" @click="getSig('decide')" v-if="$route.query.state != '01' && $route.query.state != '02' && decideimgs.length < 1">
				        		<i class="ion ion-android-add fontcompany"></i>
				        		<!-- <span class="bluecolor block">点击上传照片</span> -->
				        	</a>
			        	</li>						
					</ul>
		        	
	       		</div>
			</div>


			<div class="form-title clearFix">
				<p>现场照片</p>
			</div>
			<div class="form-group uploadimage" id="uploadsceneimage">
				<ul>
					<li v-for="(img,index) in scenePicimgs">
						<img :src="img" @click="previewImg(img)"/>
						<i class="ion ion-ios-close" v-if="$route.query.state != '01' && $route.query.state != '02'" @click.stop.prevent="delImg('scene',img,index)"></i>
					</li>
					<li>
						<a class="companypic" id="chooseImages" @click="getSig('scene')" v-if="$route.query.state != '01' && $route.query.state != '02' && scenePicimgs.length < 6">
			        		<i class="ion ion-android-add fontcompany"></i>
			        		<!-- <span class="bluecolor block">点击上传照片</span> -->
			        	</a>
					</li>					
				</ul>	        	
       		</div>

       		<div class="form-title clearFix">
				<p>车损照片</p>
			</div>
			<div class="form-group uploadimage" id="uploaddamageimage">
				<ul>
					<li v-for="(img,index) in damageCarimgs">
						<img :src="img" @click="previewDamageCarImg(img)"/>
						<i class="ion ion-ios-close" v-if="$route.query.state != '01' && $route.query.state != '02'" @click.stop.prevent="delImg('damage',img,index)"></i>
					</li>
					<li>
						<a class="companypic" id="chooseCarImages" @click="getSig('damage')" v-if="$route.query.state != '01' && $route.query.state != '02' && damageCarimgs.length < 6">
			        		<i class="ion ion-android-add fontcompany"></i>
			        		<!-- <span class="bluecolor block">点击上传照片</span> -->
			        	</a>
					</li>					
				</ul>
       		</div>
<!-- 
       		<div class="form-title clearFix">
				<p>人员伤亡情况 </p>
				<i class="ion ion-plus-circled fl_right" @click="openAccident" v-if="$route.query.state != '01' && $route.query.state != '02'"></i>
			</div>
			<div class="form-group">
				<table width="100%" border="0" class="form-table">
					<thead>
						<tr>
							<th width="22%">姓名</th>
							<th>类型</th>
							<th width="40">伤亡情况</th>
							<th v-if="$route.query.state != '01' && $route.query.state != '02'">操作</th>
						</tr>
					</thead>
					<tbody>
						<tr v-for="(item,index) in userAllAccident">
							<td>{{item.name}}</td>
							<td>{{item.typeName}}</td>
							<td><div  style="width:100px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">{{item.casualties}}</div></td>
							<td v-if="$route.query.state != '01' && $route.query.state != '02'"><i class="ion ion-ios-close" @click="deltable($event,index)"></i></td>
						</tr>
					</tbody>
				</table>
			</div>
 -->

       		<div class="savebtn" v-if="$route.query.state != '01' && $route.query.state != '02'">
	       		<button type="button" class="" @click="savenm('00')">保存</button>
	       		<button type="button" class="" @click="savenm('01')">保存并提交</button>
	   		</div>
		</form>
		
		<!-- 选择我车位置 -->
		<div class="carPosition" v-if="isOpen" id="carDialog">
			<div class="dialog-content">
				<div class="title">
					<p>当日天气情况：</p>
				</div>
				<div class="options">
<!-- 					<label v-for="site in carPosition" v-if="isState == 'carposition'">
						<input type="checkbox" name="" v-bind:value="site.id" v-model="carPositionList"> {{site.typeName}}
					</label>
					<label v-for="site in pavementState" v-if="isState == 'roadbed'">
						<input type="checkbox" name="" v-bind:value="site.id" v-model="roadBedList"> {{site.typeName}}
					</label> -->
					<label v-for="site in weather">
						<input type="checkbox" name="" v-bind:value="site.id" v-model="weatherList"> {{site.typeName}}
					</label>
				</div>
				<div class="dialog-footer">
					<button type="button" @click="getCarData">确定</button>
					<button type="button" @click="cancle">取消</button>
				</div>
			</div>
		</div>

		<!-- 人员事故情况 -->
		<!-- <div class="carPosition" v-if="isAccident" id="accident">
			<div class="dialog-content">
				<div class="title">
					<p>伤亡人员添加：</p>
				</div>
				<div class="options">
					<form>
						<div class="form-baseinput bordernone">
							<div class="form-group formline">
								<label>姓名：</label>
								<input type="text" name="username" class="form-control" v-model="userName" placeholder="请输入姓名">
							</div>
							<div class="form-group formline">
								<label>类型：</label>
								<select class="form-control" v-model="userType" ref="userAccidentName">
									<option v-for="item in casualtiesType" :value="item.id">{{item.typeName}}</option>
								</select>
							</div>
							<div>
								<label>伤亡情况</label>
								<textarea rows="3" class="form-control" placeholder="请填写伤亡情况" v-model="userStatus"></textarea>
							</div>
						</div>
					</form>
				</div>
				<div class="dialog-footer">
					<button type="button" @click="enterUserData">确定</button>
					<button type="button" @click="cancle">取消</button>
				</div>
			</div>
		</div> -->
		<loading v-if="loadShow"></loading>
		<toast v-if="toastShow" :message="tipMessage"></toast>

		<transition name="slide">
	      <tips v-show="tipsShow" :tips="tipsMessage"></tips>
	    </transition>
	</div>
</template>
<script type="text/javascript">
	import { Group, Datetime, XInput, Selector } from 'vux'

	import wx from 'weixin-js-sdk'

	import jssdk from '../../assets/js/jssdk/wxJSSDK'

	import safeUrl from '../../assets/js/insterface'

	import http from '../../assets/js/http_mixin'

	import vaild from '../../assets/js/vaild_form'

	import city from '../../assets/js/city'

	export default {
		data () {
			return {
				stateX:true,
				isSubmit:true,// 防止保存和提交短事件内触发多次
				tipMessage:'',
				list:{
					empName:'',		  // 员工姓名
					deptName:'', 	  // 员工部门名称
					id:'',
					deptId:'',
					empNo:'',
					incidentTime:'',  // 事发时间
					incidentCn:'',    // 事故发生所在省
					incidentCity:'',  // 事故发生所在市
					incidentSite:'',  // 事发地点
					isAssess:'0',	  // 该路段是否做过道路评估 0：未评估 1:评估
					aimId:'',		  // 用车目的
					weatherState:'',  // 天气状况
					bodyState:'',     // 身体状况
					carSpeed:'',      // 当时我方车速
					roadwayCount:'',  // 车道信息
					accidentType:'',  //事故类型
					accidentName:'',
					involvePersonnel:'',  //其他涉及人员
					injuredDescribe:'',   //受伤情况描述
					// roadState:'',     // 道路状况
					// roadwayAspect:'', // 车道通行方向
					// carPosition:'',   // 我车位置
					// roadbedState:'',  // 路面状况
					carHarm:'',		  // 车辆损伤部位
					isReport:'',	  // 是否已报告
					repairAccount:'', // 车辆预计修理金额
					incidentDescribing:'',  // 事件经过简述
					incidentExperience:'',  // 经验分享

					decidePicId:'',   // 交警事故认定书
					scenePicId:'',  // 现场照片
					damageCarPicId:'',  // 车损照片
					// delAttId:[],	// 编辑时删除图片的Id

					// casualties:'',  // 伤亡人员情况
					state:''
				},

				//时间拼装
				hourSelect:[],
				miniterSelect:[],

				dateFirst:'',  //日期
				// hourNum:'00',   //小时
				// miniterNum:'00',  //分钟
				timeFirst:'',

				//事故类型
				accType:[],

				//其他涉及人员
				OtherRef:[],


				// tafficDirection:[],  //车道通行方向
				// pavementState:[], //路面状况
				// casualtiesType:[], //员伤亡情况-类型
				// carPosition:[], //我车位置
				weather:[], //天气状况
				// roadCondition:[], //道路情况
				report:[], //是否报告
				bodyState:[], //身体状况
				carAim:[], //用车目的
				laneNumber:[], //车道数量

				//是否报告转换
				isReport:[],

				isTrue:false,

				//人员事故
				// isAccident:false,
				// userName:'',
				// userType:'',
				// userStatus:'',

				// userAllAccident:[],


				//路面状况
				// roadBedList:[],
				// roadbedText:'',

				// isState:'',

				//天气情况
				weatherList:[],
				weatherText:'',


				//我车位置处理

				// carPositionList:[],
				// enterTextCar:'',


				//现场照片处理
				scenePicimgs:[],
				scenePicImgArr:[],

				//车损照片处理
				damageCarimgs:[],
				damageCarImgArr:[],

				//交警事故处理
				decideimgs:[],
				decideImgArr:[],

				idx:0,
				damageIdx:0,
				decideIdx:0,
				idx2:0,
				damageIdx2:0,
				decideIdx2:0,

				isOpen:false,
				carObj : {// 下拉框数据
					listOne: [],
					listTwo: [],
					listThree: [],
					listFour: [],
					listFive: []
				},
				carShow: []
			}
		},
		mixins:[jssdk, http, vaild],
		components : {
			Group,
			Datetime,
			XInput,
			Selector
		},
		mounted() {
			document.title="事故报告";
			city.getProvince();
			this.list.empNo = this.$route.query.empNo;
			this.stateX = this.$route.query.state=="01" || this.$route.query.state=="02"  ? true : false;
			for(var i=0; i < 24; i++){
				if(i<10){
					this.hourSelect.push({text:"0"+i,value:"0"+i})
				}else{
					this.hourSelect.push({text:i,value:i})
				}
			}
			for(var i=0; i < 60; i++){
				if(i<10){
					this.miniterSelect.push({text:"0"+i,value:"0"+i})
				}else{
					this.miniterSelect.push({text:i,value:i})
				}
			}
			this.getEmpInfor();
			this.init();
		},
		methods: {
			//获取员工数据
			getEmpInfor() {
				// if(!this.$route.query.state){
					this.$http.post(safeUrl.vehicleIncidentGetEmp,{empNo:this.list.empNo},{emulateJSON: true})
					.then((response) =>{
						// debugger;
						if(response.data.msg == "成功"){
							const dataEmp = response.data.data;

							const d = new Date();
							var months = d.getMonth() + 1;
							var days =  d.getDate();
							if(months < 10){
								months = '0' + months;
							}
							if(days < 10){
								days = '0' + days;
							}
							this.dateFirst = d.getFullYear()+"-"+months+"-"+days;
							// const d = new Date();
							// this.dateFirst = d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
							this.timeFirst = "00:00";
							this.list.empName = dataEmp.employeeName;
							this.list.deptName = dataEmp.deptName;
							this.list.deptId = dataEmp.deptId;

							this.selectData();
							
						}
						
						console.log('获取人员信息：' + JSON.stringify(response.data));
					})
					.then(function(response){
						console.log(response)
					})
				// }
			},
			//获取select数据
			selectData() {
				this.$http.post(safeUrl.vehicleIncidentAdd)
				.then((response) =>{
					var seleData = response.data.data;
					// debugger;

					this.accType = seleData.accType;
					this.OtherRef = seleData.OtherRef;
					//初始化填充，默认第一个
					// this.list.roadwayAspect = seleData.tafficDirection[0].id; 
					// this.list.roadbedState = seleData.pavementState[0].id;
					// this.list.carPosition = seleData.carPosition[0].id;
					this.list.aimId = seleData.carAim[0].id;
					this.list.weatherState = seleData.weather[0].id;
					this.list.bodyState = seleData.bodyState[0].id;
					this.list.roadwayCount = seleData.laneNumber[0].id;
					this.list.accidentType = seleData.accType[0].id;
					this.list.involvePersonnel = seleData.OtherRef[0].id;
					// this.list.roadState = seleData.roadCondition[0].id;
					// this.userType = seleData.casualtiesType[0].id;

					// this.tafficDirection = seleData.tafficDirection;
					// this.pavementState = seleData.pavementState;
					// this.casualtiesType = seleData.casualtiesType;
					// this.carPosition = seleData.carPosition;
					this.weather = seleData.weather;
					// this.roadCondition = seleData.roadCondition;
					this.report = seleData.report;
					this.bodyState = seleData.bodyState;
					this.carAim = seleData.carAim;
					this.laneNumber = seleData.laneNumber;
					//selector数据获取
					this.getCarInfo(this.accType, this.carObj.listOne);
					this.getCarInfo(this.carAim, this.carObj.listTwo);
					this.getCarInfo(this.bodyState, this.carObj.listThree);
					this.getCarInfo(this.laneNumber, this.carObj.listFour);
					this.getCarInfo(this.OtherRef, this.carObj.listFive);
					this.enterData();  

					// console.log('获取人员信息：' + JSON.stringify(response.data));
				})
				.then(function(response){
					console.log(response)
				})
			},
			enterData(){
				// debugger;
				if(this.$route.query.state && this.$route.query.state != '00'){
					this.getData();
					setTimeout(function(){
						var form = document.forms[0]; 
						for ( var i = 0; i < form.length; i++) { 
							var element = form.elements[i]; 
							element.disabled = true; 
						} 
					},10)
					
					// document.querySelectorAll("input[checkbox]").disabled = "disabled";
				}else if(this.$route.query.state == '00'){
					this.getData();
				}
			},
			getData(){
				this.$http.post(safeUrl.vehicleIncidentEdit,{id:this.$route.query.id},{emulateJSON: true})
				.then((response) =>{
					// debugger;

					city.getRegion();

					var responseData = response.data.data;

					var dateYear = responseData.incidentTime.substring(0,10);
					// var dateHour = responseData.incidentTime.substring(11,13);
					// var dateMini = responseData.incidentTime.substring(14,16);
					var dateTime = responseData.incidentTime.substring(11,16);
					// console.log(dateMini);
					this.dateFirst = dateYear;
					// debugger;
					// this.hourNum = dateHour;
					// this.miniterNum = dateMini;
					this.timeFirst = dateTime;

					this.list.incidentSite = responseData.incidentSite;

					this.list.accidentType = responseData.accidentType;
					this.list.involvePersonnel = responseData.involvePersonnel;

					this.list.injuredDescribe = responseData.injuredDescribe;

					//遍历城市获取城市信息，然后填充

					// debugger;
					var provinceName = document.getElementById("provinceValue");
					var optIndex = provinceName.childNodes;  
					for(var k=0; k<optIndex.length; k++){
						if(optIndex[k].getAttribute("indexname") == responseData.incidentCn){
							provinceName.value = optIndex[k].value;
							// debugger;
							var provinces=document.getElementById("provinceValue"); 
							var prov=provinces[provinces.selectedIndex].value; 
							var str="<select id='cityValue' class='form-control'  v-model='list.incidentCity'>"; 

							for(var i=0;i<city.getRegion()[prov].length;i++) 
							{         
								str=str+"<option value="+ city.getRegion()[prov][i] +">"+city.getRegion()[prov][i]+"</option>";     
							} 
							str=str+"</select>"; 
							document.getElementById("city").innerHTML=str; 
							break;
						}
					}

					if(this.$route.query.state && this.$route.query.state != '00'){
						var form = document.forms[0]; 
						for ( var i = 0; i < form.length; i++) { 
							var element = form.elements[i]; 
							element.disabled = true; 
						} 
					}

					var cityId = document.getElementById("cityValue");

					cityId.value = responseData.incidentCity;

					this.list.id = responseData.id;
					this.list.empName = responseData.empName;
					this.list.deptName = responseData.deptName;
					this.list.empNo = responseData.empNo;

					this.list.incidentCn = responseData.incidentCn;
					this.list.incidentCity = responseData.incidentCity;

					this.list.aimId = responseData.aimId;
					this.list.bodyState = responseData.bodyState;
					this.list.carHarm = responseData.carHarm;
					this.list.carSpeed = responseData.carSpeed;
					this.list.weatherState = responseData.weatherState;
					this.list.isAssess = responseData.isAssess;
					this.list.roadwayCount = responseData.roadwayCount;
					// this.list.roadState = responseData.roadState;
					// this.list.roadwayAspect = responseData.roadwayAspect;
					this.list.incidentDescribing = responseData.incidentDescribing;
					this.isReport = responseData.isReport.split(",");
					this.list.repairAccount = responseData.repairAccount;
					this.list.incidentExperience = responseData.incidentExperience;

					//我车位置处理
					

					// debugger;
					// var idsText = [];

					// this.carPositionList = responseData.carPosition.split(",");
					// var ids = this.carPosition;
					// for(var i=0; i<ids.length; i++){
					// 	if(this.carPositionList.indexOf(String(ids[i].id)) != -1){
					// 		idsText.push(ids[i].typeName);
					// 	}
					// }
					// this.enterTextCar = idsText.join(",");


					//是否已报告处理显示隐藏

					for(var i=0; i<this.isReport.length; i++){
						for(var j=0; j<this.report.length; j++){
							this.report
							if(this.report[j].id == this.isReport[i] && this.report[j].typeName == "警方"){
								this.isTrue = true;
							}
						}
					}
					this.isReport



					//路面状况处理
					// debugger;
					// var carText = [];

					// this.roadBedList = responseData.roadbedState.split(",");
					// var cars = this.pavementState;
					// for(var i=0; i<cars.length; i++){
					// 	if(this.roadBedList.indexOf(String(cars[i].id)) != -1){
					// 		carText.push(cars[i].typeName);
					// 	}
					// }
					// this.roadbedText = carText.join(",");

					//天气情况处理

					var weatherTexts = [];

					this.weatherList = responseData.weatherState.split(",");
					var weathers = this.weather;
					for(var i=0; i<weathers.length; i++){
						if(this.weatherList.indexOf(String(weathers[i].id)) != -1){
							weatherTexts.push(weathers[i].typeName);
						}
					}
					this.weatherText = weatherTexts.join(",");


					//事故伤亡情况处理
					// for(var i=0; i<responseData.casualtiesList.length; i++){
					// 	for(var j=0; j<this.casualtiesType.length; j++){
					// 		if(responseData.casualtiesList[i].type == this.casualtiesType[j].id){
					// 			responseData.casualtiesList[i].typeName = this.casualtiesType[j].typeName;
					// 		}
					// 	}
					// }
					// this.userAllAccident = responseData.casualtiesList;


					//现场照片处理
					if(responseData.scenePicStr != "" && responseData.scenePicStr != null){
						const imgArr = responseData.scenePicStr.split(",")
						for(var j=0; j<imgArr.length; j++){
							this.scenePicImgArr.push(imgArr[j]);
						}
						this.scenePicimgs = imgArr;
					}


					//车损照片处理
					if(responseData.damageCarPicStr != "" && responseData.damageCarPicStr != null){
						const imgArr = responseData.damageCarPicStr.split(",")
						for(var j=0; j<imgArr.length; j++){
							this.damageCarImgArr.push(imgArr[j]);
						}
						this.damageCarimgs = imgArr;
					}

					//车损照片处理
					if(responseData.decide != "" && responseData.decide != null){
						const imgArr = responseData.decide.split(",")
						for(var j=0; j<imgArr.length; j++){
							this.decideImgArr.push(imgArr[j]);
						}
						this.decideimgs = imgArr;
					}


					console.log(response.data.data)
					// debugger;
				})
				.then(function(response){
					console.log(response)
				})
			},
			getCarInfo(typeo, typet){
				for (var i = 0; i < typeo.length; i++){
					typet.push({
						key: typeo[i].id,
						value: typeo[i].typeName
					})
				}
			},
			//现场选择图片
			getSig(type) {
				var vue = this;
				var chooseImageID = [];
				if(type == 'scene'){
					this.imageApi({
						chooseImage:{
							count:6 - vue.scenePicimgs.length,
							success:function(res){
								chooseImageID = res.localIds;
								if(chooseImageID[0].toString().indexOf("wxLocalResource") != -1){
									vue.getSceneLocalImg(chooseImageID);    
								}else{
									for(var i=0; i<chooseImageID.length; i++){
										vue.scenePicimgs.push(chooseImageID[i]);
									}
								}
								// vue.imglength = vue.imgs.length;
								vue.syncUpload(chooseImageID);
								console.log("gongsi------------" + chooseImageID);
							}
						}
					})
				}else if(type == 'damage'){
					this.imageApi({
						chooseImage:{
							count:6 - vue.damageCarimgs.length,
							success:function(res){
								chooseImageID = res.localIds;
								if(chooseImageID[0].toString().indexOf("wxLocalResource") != -1){
									vue.getDamageLocalImg(chooseImageID);    
								}else{
									for(var i=0; i<chooseImageID.length; i++){
										vue.damageCarimgs.push(chooseImageID[i]);
									}
								}
								
								// vue.imglength = vue.imgs.length;
								vue.syncDamageCarUpload(chooseImageID);
								console.log("gongsi------------" + chooseImageID);
							}
						}
					})
				}else{
					this.imageApi({
						chooseImage:{
							count:1,
							success:function(res){
								chooseImageID = res.localIds;
								if(chooseImageID[0].toString().indexOf("wxLocalResource") != -1){
									vue.getDecideLocalImg(chooseImageID);    
								}else{
									for(var i=0; i<chooseImageID.length; i++){
										vue.decideimgs.push(chooseImageID[i]);
									}
								}
								// vue.imglength = vue.imgs.length;
								vue.syncDecideUpload(chooseImageID);
								console.log("gongsi------------" + chooseImageID);
							}
						}
					})
				}
			},
			//现场图片流
			getSceneLocalImg(eve){
		        var _this = this;
		        _this.imageApi({
					getLocalImgData:{
						localId: eve[_this.idx2].toString(),
						success: function (res) {
							_this.idx2++;
							_this.scenePicimgs.push(res.localData.toString());
							if (_this.idx2 < eve.length) {
								_this.getSceneLocalImg(eve);   
							} else {
								_this.idx2 = 0;
							}
						}
					}
		        });    
		    },
		    //车损图片流
		    getDamageLocalImg(eve){
		        var _this = this;
		        _this.imageApi({
					getLocalImgData:{
						localId: eve[_this.damageIdx2].toString(),
						success: function (res) {
							_this.damageIdx2++;
							_this.damageCarimgs.push(res.localData.toString());
							if (_this.damageIdx2 < eve.length) {
								_this.getDamageLocalImg(eve);   
							} else {
								_this.damageIdx2 = 0;
							}
						}
					}
		        });    
		    },
		    //警方事故照片流
		    getDecideLocalImg(eve){
		        var _this = this;
		        _this.imageApi({
					getLocalImgData:{
						localId: eve[_this.decideIdx2].toString(),
						success: function (res) {
							_this.decideIdx2++;
							_this.decideimgs.push(res.localData.toString());
							if (_this.decideIdx2 < eve.length) {
								_this.getDecideLocalImg(eve);   
							} else {
								_this.decideIdx2 = 0;
							}
						}
					}
		        });    
		    },
			//现场图片预览
			previewImg(img) {
				var vue = this;
				this.imageApi({
					previewImage:{
						current:img,
						urls:vue.scenePicimgs
					}
				})
			},
			//车损图片预览
			previewDamageCarImg(img) {
				var vue = this;
				this.imageApi({
					previewImage:{
						current:img,
						urls:vue.damageCarimgs
					}
				})
			},
			//车损图片预览
			previewDecideCarImg(img) {
				var vue = this;
				this.imageApi({
					previewImage:{
						current:img,
						urls:vue.decideimgs
					}
				})
			},
			//现场上传照片
			syncUpload (localIds){
				var vue = this;
				this.imageApi({
					uploadImage:{
						localId:localIds[vue.idx].toString(),
						success:function(res){
							vue.idx++;
							vue.scenePicImgArr.push(res.serverId);
							if(vue.idx<localIds.length){
								vue.syncUpload(localIds);
							}else{
								vue.idx = 0;
							}
						}
					}
				})
			},
			//车损上传照片
			syncDamageCarUpload (localIds){
				var vue = this;
				this.imageApi({
					uploadImage:{
						localId:localIds[vue.damageIdx].toString(),
						success:function(res){
							vue.damageIdx++;
							vue.damageCarImgArr.push(res.serverId);
							if(vue.damageIdx<localIds.length){
								vue.syncDamageCarUpload(localIds);
							}else{
								vue.damageIdx = 0;
							}
						}
					}
				})
			},
			//警方事故照片
			syncDecideUpload (localIds){
				var vue = this;
				this.imageApi({
					uploadImage:{
						localId:localIds[vue.decideIdx].toString(),
						success:function(res){
							vue.decideIdx++;
							vue.decideImgArr.push(res.serverId);
							if(vue.decideIdx<localIds.length){
								vue.syncDecideUpload(localIds);
							}else{
								vue.decideIdx = 0;
							}
						}
					}
				})
			},
			savenm(e) {
				if(e == "01"){
					var oInput = document.forms[0].elements;
					var xDiv = document.getElementsByClassName('ipt') //获取Xinput组件父级节点
					if(!this.vaildxIpt(xDiv)){                        // 调用vaildxInpt方法判断
						return false;
					}
			        if (!this.vaildForm(oInput)) {
			          return false
			        }
		        }
				var vue = this;
				//状态处理
				this.list.state = e;

				//时间日期处理
				this.list.incidentTime = this.dateFirst + " " + this.timeFirst;

				//是否已报告处理
				this.list.isReport = this.isReport.join(",");

				this.accType.map(function(){
					if(vue.list.accidentType == arguments[0].id){
						vue.list.accidentName = arguments[0].typeName;
					}
				});
				// debugger;
				//省市处理
				var provinceName = document.getElementById("provinceValue");
				var optIndex = provinceName.selectedIndex;  
				var textOption = provinceName.options[optIndex].getAttribute("indexname");  
				this.list.incidentCn = textOption;
				this.list.incidentCity = document.getElementById("cityValue").value;

				//现场图片处理
				this.list.scenePicId = this.scenePicImgArr.join(",");

				//车损图片处理
				this.list.damageCarPicId = this.damageCarImgArr.join(",");

				//警方事故处理
				if(this.isTrue){
					this.list.decidePicId = this.decideImgArr.join(",");
				}else{
					this.list.decidePicId = '';
				}
				

				//我车位置
				// this.list.carPosition = this.carPositionList.join(",");

				//道路状况
				// this.list.roadbedState = this.roadBedList.join(",");

				//天气状况
				this.list.weatherState = this.weatherList.join(",");

				//人员事故
				// for(var k=0; k<this.userAllAccident.length; k++){
				// 	this.userAllAccident[k] = JSON.stringify(this.userAllAccident[k]);
				// }
				// this.list.casualties = JSON.stringify(this.userAllAccident);

				// debugger;
				//保存操作
				if(this.isSubmit){
					this.isSubmit = false;
					setTimeout(function (){
						this.isSubmit= true;
					},2000);

					if(this.$route.query.id){
						this.getInfo({
							url:safeUrl.vehicleIncidentUpdate,
							param:this.list,
							success:function(response){
								vue.toastShow = true;
								vue.tipMessage = response.data.msg;
								setTimeout(function(){
									vue.toastShow = false;
									window.history.go(-1);
								},1500);
								console.log('updata' + response.data);
							},
							fail:function(response){

							}
						})
					}else{
						this.getInfo({
							url:safeUrl.vehicleIncidentSendAjax,
							param:this.list,
							success:function(response){
								vue.toastShow = true;
								vue.tipMessage = response.data.msg;
								setTimeout(function(){
									vue.toastShow = false;
									window.history.go(-1);
								},1500);
								console.log('send' + JSON.stringify(response.data));
							},
							fail:function(response){

							}
						})
					}
				}
				console.log(this.list)
			},
			delImg(type,img,i) {

				

				if(type == 'scene'){
					this.scenePicImgArr.splice(i,1);
					this.scenePicimgs.splice(i,1);
				}else if(type == 'damage'){
					this.damageCarImgArr.splice(i,1);
					this.damageCarimgs.splice(i,1);
				}else{
					this.decideImgArr.splice(i,1);
					this.decideimgs.splice(i,1);
				}
				
			},
			//当点击警方的时候显示添加图片
			showDecidePicId(e,item){
				if(item.typeName == "警方"){
					if(e.currentTarget.checked){
						this.isTrue = true;
					}else{
						this.isTrue = false;
					}
				}
			},
			openDiage() {
				this.isOpen = true;
			},
			getCarData() {
				// debugger;
				var ids = document.querySelectorAll("#carDialog input");
				var idsAll = [];
				var idsText = [];
				for(var i=0; i<ids.length; i++){
					if(ids[i].checked){
						idsAll.push(ids[i].value);
						idsText.push((ids[i].nextSibling.nodeValue).trim());
					}
				}
				// if(this.isState == 'carposition'){
				// 	this.list.carPosition = idsAll.join(",");
				// 	this.enterTextCar = idsText.join(",");
				// }else if(this.isState == 'roadbed'){
				// 	this.list.roadbedState = idsAll.join(",");
				// 	this.roadbedText = idsText.join(",");
				// }else{
					this.list.weatherState = idsAll.join(",");
					this.weatherText = idsText.join(",");
				// }
				this.isOpen = false;
			},
			cancle() {
				this.isOpen = false;
				// this.isAccident = false;
				this.userName = '';
				this.userType = '';
				this.userStatus = '';
			},

			//人员事故方法
			// openAccident() {
			// 	this.userType = this.casualtiesType[0].id;
			// 	// this.isAccident = true;
			// },
			enterUserData() {

				var vue = this;

				if(this.userName == ""){		
			        this.tipsShow = true;
			        this.tipsMessage = "请输入姓名";
			        window.setTimeout(function () {
			          /*两秒后，弹窗消失*/
			          vue.tipsShow = false;
			          vue.tipsMessage = '';
			        }, 2000);

			        return false
				}
				if(this.userStatus == ""){
					this.tipsShow = true;
			        this.tipsMessage = "请输入伤亡情况";
			        window.setTimeout(function () {
			          /*两秒后，弹窗消失*/
			          vue.tipsShow = false;
			          vue.tipsMessage = '';
			        }, 2000);

			        return false
				}

				var typeNames = this.$refs.userAccidentName;
				var typeName = typeNames.options[typeNames.selectedIndex].text;
				this.userAllAccident.push({name:this.userName,type:this.userType,typeName:typeName,casualties:this.userStatus});
				this.userName = '';
				this.userType = '';
				this.userStatus = '';
				// debugger;
				console.log(this.userAllAccident);
				this.isAccident = false;

			},
			deltable(e,item) {
				this.userAllAccident.splice(item,1);
			}
		}
	}
</script>